<div class="modal fade bs-modal-lg" id="modelContent">
	<div class="modal-dialog modal-lg">
        <div class="modal-content"></div>
    </div>
</div> 

<div class="portlet box green">
    <div class="portlet-title">
		<div class="caption"><i class="fa fa-cogs"></i>订单 &gt; 订单管理 &gt; 订单列表</div>
		<div class="tools"><a href="javascript:;" class="collapse" data-original-title="" title=""> </a></div>
    </div>
    <div style="background-color: rgb(249, 247, 161);">
		<label >
		注：1.系统会员在商城选购、扫货品二维码、或者点击货品链接将货品加入购物车，且下单时选择物流发货的所有订单。<br/>
       2.未付款订单为买家下单还未支付的订单，待发货的订单为已付款商家未发货订单，待收货指商家已发货买家未收货订单，
         已完成指买家已确定收货订单，已取消指买家下单后未付款被取消的订单和买家下单付完款单申请取消订单成功的订单。</label>
	</div>
    <div class="portlet-body">
    	<div class="tabbable-line ">
			<ul class="nav nav-tabs ">
				<li #if(!$!searchModel.orderState) class="active" #end><a href="/order/list" class="ajaxify">全部订单
				</a></li>
				<li #if($!searchModel.orderState == 'INIT_STATE') class="active" #end ><a href="/order/list?orderState=INIT_STATE" class="ajaxify">未确认</a></li>
				<li #if($!searchModel.orderState == 'WAIT_BUYER_PAY') class="active" #end ><a href="/order/list?orderState=WAIT_BUYER_PAY" class="ajaxify">未付款</a></li>
				<li #if($!searchModel.orderState == 'WAIT_DELIVERY') class="active" #end ><a href="/order/list?orderState=WAIT_DELIVERY" class="ajaxify">待发货</a></li>
				<li #if($!searchModel.orderState == 'WAIT_REVICE') class="active" #end ><a href="/order/list?orderState=WAIT_REVICE" class="ajaxify">待收货</a></li>
				<li #if($!searchModel.orderState == 'TRADE_FINISHED') class="active" #end ><a href="/order/list?orderState=TRADE_FINISHED" class="ajaxify">已完成</a></li>
				<li #if($!searchModel.orderState == 'CANCEL') class="active" #end ><a href="/order/list?orderState=CANCEL" class="ajaxify">已取消</a></li>
			</ul>
			<div class="tab-content">
				<div class="tab-pane active form">
					
				</div>
			</div>
		</div>
		<div class="portlet-body form">
		   	<form action="/order/list" class="form-horizontal" method="get" id="searchForm" onsubmit="return false">
				<div class="form-body">
					<div class="row">
						<div class="col-md-2">
							<label class="col-md-4 control-label">订单号：</label>
							<div class="col-md-8">
						    	<input type="text" class="form-control" name="id" id="orderId" value="$!searchModel.id">
						    	<input type="hidden" name="orderState" id ='orderState' value="$!searchModel.orderState" />
							</div>
						</div>
						<div class="col-md-2">
							<label class="col-md-4 control-label">购买会员：</label>
							<div class="col-md-8">
						    	<input type="text" class="form-control" name="username" value="$!searchModel.username">
							</div>
						</div>
						<div class="col-md-2">
							<label class="col-md-4 control-label">支付类型：</label>
							<div class="col-md-8">
						    	<select name="settleWay" class="form-control">
								<option value="">全部</option>
		                    	<option value="WECHAT" #if($!searchModel.settleWay=='WECHAT') selected #end>微信支付</option>
		                        <option value="ALIPAY" #if($!searchModel.settleWay=='ALIPAY') selected #end>支付宝支付</option>
		                        <option value="CREDIT" #if($!searchModel.settleWay=='CREDIT') selected #end>信用支付</option>
		                    </select>
							</div>
						</div>
						<div class="col-md-4">
							<label class="col-md-3 control-label">下单时间：</label>
							<div class="col-md-4">
						    	<input type="text" class="form-control" readOnly id="startTime" name="startTime" value="$!startTime">
						    	<i class="fa fa-calendar" style="position: absolute;right: 10px;top: 10px"></i>
							</div>
							<div class="col-md-1">~</div>
							<div class="col-md-4">
						    	<input type="text" class="form-control"readOnly id="endTime" name="endTime" value="$!endTime">
						    	<i class="fa fa-calendar" style="position: absolute;right: 10px;top: 10px"></i>
							</div>
						</div>
						<div class="col-md-2">
							<div class="actions col-md-12">
								<a href="javascript:;" class="btn green btn-sm fa-search-sendGoods"><i class="fa fa-search"></i> 查询 </a>
								<a href="#modelContent" thref="/sendGoods/add?id=$!searchModel.id" class="btn green btn-sm hidden open-send-goods ajax-model-get" data-toggle="modal"><i class="fa "></i> 查询 </a>
								<a href="javascript:;" class="btn green btn-sm search-reset"><i class="fa fa-eraser"></i> 清除 </a>
							</div>
						</div>
		    		</div>
				</div>
			</form>
		</div>
		<script type="text/javascript">
		$("#orderId").keydown(function() {
			if (event.keyCode == "13") {//keyCode=13是回车键
				$('.fa-search-sendGoods').click() ;
				return ;
		    };
		});
	    $('.page-content').off('click','.actions .fa-search-sendGoods').on('click', '.actions .fa-search-sendGoods', function (e) {
	        e.preventDefault();
			
	        var id = $('#orderId').val() ;
	        var orderState = $('#orderState').val() ;
	        if(orderState == 'WAIT_DELIVERY' ) {
	        	if(id.length >0 ) {
	        		if(id.substring(id.length-1)=='+') {
	        			$('.open-send-goods').attr('thref','/sendGoods/add?id='+id) ;
	        			$('.open-send-goods').click() ;
	        			return ;
	        		}
	        	}
	        }
	        
	        
	        
	        var url = $("#searchForm").attr("action");
	        var pageContent = $('.page-content');
	        var pageContentBody = $('.page-content .page-content-body');
	        
	        App.startPageLoading();
	        
	        var resBreakpointMd="320px;"
	
	        if (App.getViewPort().width < resBreakpointMd && $('.page-sidebar').hasClass("in")) { // close the menu on mobile view while laoding a page 
	            $('.page-header .responsive-toggler').click();
	        }
        	$.ajax({
        		type: "GET",
        		cache: false,
        		url: url,
        		dataType: "html",
        		data: $("#searchForm").serialize(),
        		success : function(res) {
        			App.stopPageLoading();
        			pageContentBody.html(res);
        			Layout.fixContentHeight(); // fix content height
        		},
        		error: function (xhr, ajaxOptions, thrownError) {
	                pageContentBody.html('<h4>服务器异常，请与管理员联系.</h4>');
	                App.stopPageLoading();
	            }
        	})
	    });
	    
	    $('.page-content').keydown(function() {
			if (event.keyCode == "13") {//keyCode=13是回车键
				$('.actions .ajax-search').click();
		    };
		    return ;
		});
	    
		</script>
    	<div class="dataTables_wrapper no-footer">
			<div class="table-scrollable">
			    <table class="table table-striped table-bordered table-hover">
				  	<thead>
						<tr>
		   		 			<th>订单号</th>
		   		 			<th>订单金额</th>
		   		 			<th>支付类型</th>
		   		 			<th>订单状态</th>
		   		 			<th>企业名称</th>
		   		 			<th>购买会员</th>
		   		 			<th>备注</th>
<!-- 		   		 			<th>售后</th> -->
		   		 			<th>下单时间</th>
		   		 			<th>付款时间</th>
		   		 			<th>打印</th>
							<th class="col-md-2">操作</th>
						</tr>
					</thead>
					<tbody>
					#foreach($item in $pageOrder.result)
		  				<tr>
						    <td>
							    <a class="btn btn-outline btn-sm ajaxify" href="/order/edit?orderId=$!item.id"> 
							    	$!item.id
							    </a>
						    </td>
						    <td>$!item.total</td>
						    <td>$!item.settleWay.name</td>
						    <td>$!item.orderState.name</td>
						    <td>$!item.company</td>
						    <td>$!item.username</td>
						    <td>#if($!item.note.isEmpty()) × #else √ #end</td>
<!-- 						    <td></td> -->
						    <td>$!item.createDate</td>
						    <td>$!item.payDate</td>
			    			<td>							 
			    				<a href="#modelContent" class="ajax-model-get" data-toggle="modal" thref="/order/printOrder?id=$!item.id&templatePrintType=PRINT_SHOPPING_LIST" >购 </a>
			    				<a href="#modelContent" class="ajax-model-get" data-toggle="modal" thref="/order/printOrder?id=$!item.id&templatePrintType=PRINT_PACKING_LIST" >配 </a>
			    				<a href="#modelContent" class="ajax-model-get" data-toggle="modal" thref="/order/printOrder?id=$!item.id&templatePrintType=PRINT_SHOPPING_AND_PACKING">合</a>
			    				#if($!searchModel.orderState == 'WAIT_REVICE') 
			    				<a href="#modelContent"  class="ajax-model-get" data-toggle="modal" thref="/order/printExpress?id=$!item.id">递</a>
			    				#end 
			    			</td>
			    			<td>
						    	<a class="btn green btn-outline btn-sm ajaxify" href="/order/edit?orderId=$!item.id"> 
									<i class="fa fa-edit"></i>编辑
								</a>
						    </td>		  			
		  				</tr>
					#end
					</tbody>
				</table>
			</div>
			#set($page=$pageOrder)
			#set($pageUrl="/order/list?orderState=$!searchModel.orderState&id=$!searchModel.id&
				username=$!searchModel.username&settleWay=$!searchModel.settleWay&
				startTime=$!startTime&endTime=$!endTime&pageNo=")
			#parse("_page.htm")
		</div>
    </div>
</div>
<script src="/assets/scripts/views-date.js" type="text/javascript"></script>
<script type="text/javascript">

ComponentsSelect2.initWithSearch()
MyTouchSpin.init()

</script>
<script type="text/javascript">
$("input[name= id]").focus();
</script>
